import Vue from 'vue'
import Vuex from 'vuex'

import axios from 'axios'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    staList: []
  },
  mutations: {
    mutSetList(state, args) {
      state.staList = args.list
    },
    mutAddItem(state, args) {
      const obj = {
        id: Date.now(),
        info: args.info,
        done: false
      }
      state.staList.push(obj)
    }
  },
  actions: {
    async actGetList(context) {
      const res = await axios.get('list.json')
      console.log(res)
      context.commit('mutSetList', { list: res.data })
    }
  },
  modules: {}
})
